package com.itcast.donkey.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itcast.donkey.R;
import com.itcast.donkey.adapters.DetailedTravelInContentAdapter;
import com.itcast.donkey.modles.DetailedTravel_area_Modles;

/**
 * Created by lanouhn on 16/8/31.
 */
public class DetailedTravelAreaInContentActivity extends AppCompatActivity implements View.OnClickListener {

    private LinearLayout linScenicSpot;
    private ImageView backScenicApot;
    private ImageView ivChanScenicSpot;
    private TextView tvTitleScenicSpot;
    private RecyclerView recyclerviewDetailedTravelInContent;

    private DetailedTravel_area_Modles.AttractionTripTagsBean.AttractionContentsBean contentsBean;

    private DetailedTravelInContentAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detailed_travel_in_content);
        initView();
        initData();
        initEvent();

    }

    private void initView() {
        linScenicSpot = (LinearLayout) findViewById(R.id.lin_scenic_spot);
        backScenicApot = (ImageView) findViewById(R.id.back_scenic_apot);
        ivChanScenicSpot = (ImageView) findViewById(R.id.iv_chan_scenic_spot);
        tvTitleScenicSpot = (TextView) findViewById(R.id.tv_title_scenic_spot);
        recyclerviewDetailedTravelInContent = (RecyclerView) findViewById(R.id.recyclerview_detailed_travel_in_content);
    }

    private void initData() {
        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        contentsBean = (DetailedTravel_area_Modles.AttractionTripTagsBean.AttractionContentsBean) intent.getSerializableExtra("contents");
        tvTitleScenicSpot.setText(name);
        adapter = new DetailedTravelInContentAdapter(DetailedTravelAreaInContentActivity.this, contentsBean);
        recyclerviewDetailedTravelInContent.setAdapter(adapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerviewDetailedTravelInContent.setLayoutManager(linearLayoutManager);

    }

    private void initEvent() {
        backScenicApot.setOnClickListener(this);
        ivChanScenicSpot.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.back_scenic_apot:
            case R.id.iv_chan_scenic_spot:
                finish();
                break;
        }
    }
}
